package com.by.zhdoctor.repository;

import com.by.zhdoctor.domain.Topic;

import com.by.zhdoctor.service.dto.TopicDTO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.*;

import java.util.List;

/**
 * Spring Data JPA repository for the Topic entity.
 */
@SuppressWarnings("unused")
public interface TopicRepository extends JpaRepository<Topic,Long> {
    Page<Topic> findBycomunity(String comunity, Pageable pageable);
    @Query(value = "select new com.by.zhdoctor.service.dto.TopicDTO(t,u.headimg,u.nickname) from Topic t join Userinfo u on t.creater=u.phonenumber where t.comunity=?1" )
    Page<TopicDTO> getTopicwithAvatarbycommunity(String comunity, Pageable pageable);

    List<Topic> findBycomunity(String comunity);

    @Query(value = "select new com.by.zhdoctor.service.dto.TopicDTO(t,u.headimg,u.nickname) from Topic t join Userinfo u on t.creater=u.phonenumber")
    Page<TopicDTO> findAllTopic(Pageable pageable);

}
